package com.td.core.communication.obj;

import com.td.core.communication.Sendable;

public class PlayerInfo implements Sendable<PlayerInfo> {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private int number;
	private String name;
	
	public PlayerInfo() {
		number = 0;
		name = "";
	}
	
	public PlayerInfo(PlayerInfo pi) {
		number = pi.number;
		//if(pi.name != null)
			name = new String(pi.name);
	}
	
	public synchronized int getNumber() {
		return number;
	}

	public synchronized void setNumber(int number) {
		this.number = number;
	}

	public synchronized String getName() {
		return name;
	}

	public synchronized void setName(String name) {
		this.name = name;
	}

	@Override
	public void copyTo(PlayerInfo obj) {
		synchronized (obj) {
			obj.number = this.number;
			if(this.name != null)
				obj.name = new String(this.name);
		}
	}

	@Override
	public PlayerInfo getCopy() {
		return new PlayerInfo(this);
	}
}
